package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BasePeopleInfo;
import com.ruoyi.system.service.IBasePeopleInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ryglController
 * 
 * @author ruoyi
 * @date 2022-03-18
 */
@Controller
@RequestMapping("/system/info")
public class BasePeopleInfoController extends BaseController
{
    private String prefix = "system/info";

    @Autowired
    private IBasePeopleInfoService basePeopleInfoService;

    @RequiresPermissions("system:info:view")
    @GetMapping()
    public String info()
    {
        return prefix + "/info";
    }

    /**
     * 查询rygl列表
     */
    @RequiresPermissions("system:info:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BasePeopleInfo basePeopleInfo)
    {
        startPage();
        List<BasePeopleInfo> list = basePeopleInfoService.selectBasePeopleInfoList(basePeopleInfo);
        return getDataTable(list);
    }

    /**
     * 导出rygl列表
     */
    @RequiresPermissions("system:info:export")
    @Log(title = "rygl", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BasePeopleInfo basePeopleInfo)
    {
        List<BasePeopleInfo> list = basePeopleInfoService.selectBasePeopleInfoList(basePeopleInfo);
        ExcelUtil<BasePeopleInfo> util = new ExcelUtil<BasePeopleInfo>(BasePeopleInfo.class);
        return util.exportExcel(list, "rygl数据");
    }

    /**
     * 新增rygl
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存rygl
     */
    @RequiresPermissions("system:info:add")
    @Log(title = "rygl", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BasePeopleInfo basePeopleInfo)
    {
        return toAjax(basePeopleInfoService.insertBasePeopleInfo(basePeopleInfo));
    }

    /**
     * 修改rygl
     */
    @RequiresPermissions("system:info:edit")
    @GetMapping("/edit/{idNo}")
    public String edit(@PathVariable("idNo") String idNo, ModelMap mmap)
    {
        BasePeopleInfo basePeopleInfo = basePeopleInfoService.selectBasePeopleInfoByIdNo(idNo);
        mmap.put("basePeopleInfo", basePeopleInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存rygl
     */
    @RequiresPermissions("system:info:edit")
    @Log(title = "rygl", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BasePeopleInfo basePeopleInfo)
    {
        return toAjax(basePeopleInfoService.updateBasePeopleInfo(basePeopleInfo));
    }

    /**
     * 删除rygl
     */
    @RequiresPermissions("system:info:remove")
    @Log(title = "rygl", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(basePeopleInfoService.deleteBasePeopleInfoByIdNos(ids));
    }
}
